unit Td_PosCounter_List;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, BaseDataListForm, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore,
  dxSkinsDefaultPainters, cxStyles, dxSkinscxPCPainter,
  cxDataStorage, DB, cxDBData, Menus, DBActns,
  StdActns, ActnList, ImgList, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
  cxLabel, ExtCtrls, MisString, YBDBCtrlSet,
  cxCheckBox, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  StdCtrls, cxGridCustomPopupMenu, dxSkinsForm,
  cxNavigator,
  System.Actions, cxCustomData, cxFilter, cxData, cxGridPopupMenu, MemDS,
  DBAccess, Uni, System.ImageList, cxGridLevel, cxButtons, Vcl.ExtDlgs;

type
  TfrmTd_PosCounter_List = class(TfrmBaseDataListForm)
    code: TcxGridDBColumn;
    name: TcxGridDBColumn;
    memo: TcxGridDBColumn;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }

  protected
    function AppendRecord: Boolean; override;
    function EditRecord: Boolean; override;
  public
    { Public declarations }
  end;

var
  frmTd_PosCounter_List: TfrmTd_PosCounter_List;

implementation

uses Td_PosCounter_Edit, GlobalVar;

{$R *.dfm}


procedure TfrmTd_PosCounter_List.FormCreate(Sender: TObject);
begin
  FKeyField := 'id';
  FCodeField := 'code';
  FTableName := 'td_poscounter';
  inherited;

end;

function TfrmTd_PosCounter_List.AppendRecord: Boolean;
begin
  ShowEditForm(frmTd_PosCounter_Edit, TfrmTd_PosCounter_Edit, et_New);
  Result := True;
end;

function TfrmTd_PosCounter_List.EditRecord: Boolean;
var
  bGridMode: Boolean;
  iCurrKeyID: integer;
begin
  iCurrKeyID := MainDataSource.DataSet.FieldByName(FKeyField).AsInteger;
  try
    SQLWait_CURSOR;
    MainDataGrid.ActiveView.BeginUpdate;
    bGridMode := MainDataGridDBTableView.DataController.DataModeController.GridMode;
    MainDataGridDBTableView.DataController.DataModeController.GridMode := True;
    MainDataSource.DataSet.Locate(FKeyField, iCurrKeyID, [loCaseInsensitive]);
    ShowEditForm(frmTd_PosCounter_Edit, TfrmTd_PosCounter_Edit, et_Modify);
    MainDataGridDBTableView.DataController.DataModeController.GridMode := bGridMode;
  finally
    MainDataGrid.ActiveView.EndUpdate;
    DEFAULT_CURSOR;
  end;
  Result := True;
end;


end.
